<?
include_once "gblinclude.lib";
include_once "./lib/fileselectlist.lib";

if ($_POST["submit_select"])
{
	if ($_POST["select_type"] == 2)
	{
		$path = implode(";", $_POST["file_path"]);
	}
	else if ($_POST["select_type"] == 1)
	{
		$path = $_POST["file_path"];
	}
	
	echo '<script>
			window.opener.'.$_GET['cb'].'("'.$path.'");
			window.opener.focus();
			window.close();
		</script>';
	exit;
}

global $gblConfigParam;

$tmp = getenv("DOCUMENT_ROOT");
if (substr($tmp,-1) != "/")
	$tmp .= "/";
$root = str_replace('/www/', '/'.$gblConfigParam["StorageRoot"], $tmp);
	
if (!isset($_GET["dir"]))
	$dir = $root;
else
	$dir = base64_decode(urldecode($_GET["dir"]));
$fileSelect = new CFileSelectList($dir, $root);
$layoutFactory = new CLayoutFactory();

$header = $layoutFactory->getHeader();
$tail = $layoutFactory->getTail();
$body = $fileSelect->layout();

$js = '';

echo $header.$js.$body.$tail;

?>
